/*
 * @Author: Zhaoq 1327153842@qq.com
 * @Date: 2022-09-01 09:59:52
 * @LastEditors: Zhaoq 1327153842@qq.com
 * @LastEditTime: 2022-09-01 14:17:57
 * @Gitee: https://gitee.com/REINOVO
 * Copyright (c) 2022 by 深圳市元创兴科技, All Rights Reserved. 
 * @Description: 
 */

#ifndef __REINOVO_YDLIDAR_NODELET_FIRST_H_
#define __REINOVO_YDLIDAR_NODELET_FIRST_H_
#include <pluginlib/class_list_macros.h>
#include <memory>
#include <thread>
#include "std_srvs/Empty.h"
#include <nodelet/nodelet.h>
#include <src/CYdLidar.h>
#include <ydlidar_config.h>
#include <sensor_msgs/LaserScan.h>
#include <ros/ros.h>
#define SDKROSVerision "1.0.2"
namespace rei_ydlidar
{
class ReiYdlidar : public nodelet::Nodelet
{
private:
    /* data */
    virtual void onInit();
    bool stop_scan(std_srvs::Empty::Request &req,
               std_srvs::Empty::Response &res) {
        ROS_DEBUG("Stop scan");
        return ydlidar_->turnOff();
    }

    bool start_scan(std_srvs::Empty::Request &req,
                    std_srvs::Empty::Response &res) {
        ROS_DEBUG("Start scan");
        return ydlidar_->turnOn();
    }
    void run();
public:
    ~ReiYdlidar();
private:
    ros::Publisher scan_pub;
    ros::ServiceServer stop_scan_service;
    ros::ServiceServer start_scan_service;
    std::string str_optvalue = "/dev/ydlidar";
    std::string frame_id = "laser_frame";
    int optval = 230400;
    bool b_optvalue = false;
    float f_optvalue = 180.0f;
    bool point_cloud_preservative = false;
    bool invalid_range_is_inf = false;
    std::shared_ptr<CYdLidar> ydlidar_;
    std::shared_ptr<std::thread> publish_scan_thread_;

};
} // namespace rei_ydlidar

#endif